<?php defined('SYSPATH') or die('No direct script access.');

/**
 *Copyright www.stourweb.com
 *Author: netman
 *Desc: 客户端模块,用于H5读取client_id,client_secret
 */
class Controller_Pc_Api_V2_Client extends Controller
{


    public function before()
    {
        header("Access-Control-Allow-Origin: *");
        header("Access-Control-Allow-Headers: *");
        parent::before();

    }

    //返回一个可用的siteId,secret用于h5调用接口
    public function action_info()
    {

        if(!St_Functions::is_normal_app_install('api'))
        {
            echo json_encode(array('status'=>false,'msg'=>'api接口应用未安装'));
        }
        $row = DB::select()->from('api_client')->where('status','=',1)->execute()->current();
        if(isset($row['id']))
        {
            echo json_encode(array('status'=>true,'data'=>array('client_id'=>$row['id'],'secret_key'=>$row['secret_key'])));
        }
        else
        {
            echo json_encode(array('status'=>false,'msg'=>'未找到开启的api,请在后台添加'));
        }


    }

}
